﻿
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
}

<style>
   .newform-control {
        height: 24px;
        padding-top: 0px;
        padding-bottom: 0px;
        padding-right: 0px;
        padding-left: 5px;
        resize: none;
        border-radius: 4px;
        box-shadow: none;
        border: 1px solid #ddd;
    }
    .newformTitle {
        position: relative;
        left: 0px;
        text-align: right;
        white-space: nowrap;
        font-weight: normal;
        padding-right: 15px;
    }
.form-control:focus{
    -webkit-box-shadow:inset 0 0px 1px rgba(0,0,0,.075) !important;

}
</style>

<div class="topPanel">
    <div class="toolbar">
        <div class="btn-group">
            <a id="NF-add" class="btn btn-primary" onclick="btn_add()"><i class="fa fa-plus"></i>新建</a>
        </div>
        <div class="btn-group">
            <a id="NF-edit" class="btn btn-primary" onclick="btn_edit()"><i class="fa fa-pencil-square-o"></i>修改</a>
        </div>
        <div class="btn-group">
            <a id="NF-delete" class="btn btn-primary dropdown-text" onclick="btn_delete()"><i class="fa fa-trash-o"></i>删除</a>
        </div>
    </div>
    <div class="search">
        <table>
            <tr>
                <th class="newformTitle">关键字：</th>
                <td>
                    <input id="keyword" type="text" class="newform-control form-control" placeholder="科室/医生" style="width: 75%;">
                </td>
                <th class="newformTitle">类型：</th>
                <td style="width: 28%;">
                    @Html.DropDownList("reminderType", Newtouch.Infrastructure.EnmuReminderType.金额上限提醒.ToDescSelectList(), "全部", new { @class = "newform-control form-control required", @style = "width: 100%;" })
                </td>
                <td>
                    <input type="button" id="btn_search" class="btn btn-primary" style="width:122%;margin-left:146%;" value="查询">
                </td>
            </tr>
        </table>
    </div>
</div>
<div class="gridPanel">
    <table id="gridList"></table>
    <div id="gridPager"></div>
</div>

<script>
    $(function () {
        gridList();

        $('#reminderType').select2({
            minimumResultsForSearch: -1
        });
    });

    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            url: "/SystemManage/MoneyUpperLimitReminder/GetAllList",
            postData: getSearchPostData(),
            height: 400,
            colModel: [
            { label: "sxtxId", name: "sxtxId", width: 100, align: "left", hidden: true },
            { label: "科室", name: "ks", width: 130, align: "left" },
            { label: "医生", name: "ys", width: 130, align: "left" },
            { label: "金额上限(元)", name: "jesx", width: 130, align: "left" },
            {
                label: "提醒类型", name: "reminderType", width: 130, align: "left",
                formatter: function (cellvalue) {
                    if (cellvalue === 1) { return "金额上限提醒"; }
                    else { return ""; }
                }
            },
            {
                label: "有效", name: "zt", width: 130, align: "center", formatter: function (cellvalue) {
                    return cellvalue == "1" ? "<i class=\"fa fa-toggle-on\"></i>" : "<i class=\"fa fa-toggle-off\"></i>";
                }
            },
            { label: '创建时间', name: 'CreateTime', width: 150, align: 'left', formatter: "date", formatoptions: { srcformat: 'Y-m-d', newformat: 'Y-m-d' } },
            { label: '最后修改时间', name: 'LastModifyTime', width: 150, align: 'left', formatter: "date", formatoptions: { srcformat: 'Y-m-d', newformat: 'Y-m-d' } }
            ],
            pager: "#gridPager",
            sortname: 'CreateTime desc',
            viewrecords: true,
        });
        $("#btn_search").click(function () {
            $gridList.jqGrid('setGridParam', {
                postData: getSearchPostData()
            }).trigger('reloadGrid');
        })
    }
    //查询条件
    function getSearchPostData() {
        var keyword = $("#keyword").val();
        var reminderType = $("#reminderType").val();
        return { keyword: keyword, reminderType: reminderType };
    };

    //回车事件
    $('#keyword').keydownEnterEvent(function () {
        $('#btn_search').trigger('click');
    })

    function btn_add() {
        $.modalOpen({
            id: "FormFIEdit",
            title: "提醒内容维护",
            url: "/SystemManage/MoneyUpperLimitReminder/Form",
            width: "510px",
            height: "500px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }
    //修改
    function btn_edit() {
        var keyValue = $("#gridList").jqGridRowValue().sxtxId;
        if (!!!keyValue) {
            $.modalAlert("请选中一条信息", 'warning');
            return;
        }
        $.modalOpen({
            id: "FormFIEdit",
            title: "修改信息",
            url: "/SystemManage/MoneyUpperLimitReminder/Form?sxtxId=" + keyValue,
            width: "510px",
            height: "500px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }
    //删除
    function btn_delete() {
        var seleRowid = jQuery("#gridList").jqGrid("getGridParam", "selrow");
        if (!(seleRowid)) {
            $.modalAlert("请选中一条信息", 'warning');
            return;
        }
        var sxtxId = $("#gridList").jqGridRowValue().sxtxId;
        $.deleteForm({
            url: "/SystemManage/MoneyUpperLimitReminder/DeleteForm",
            param: { sxtxId: sxtxId },
            success: function () {
                $("#btn_search").trigger('click');
            }
        })
    }

</script>
